#include <iostream>
#include <unordered_map>
using namespace std;
int n,m;
unordered_map<string,int> mp;
int main()
{
	cin>>n;
	while(n--)
	{
		string s;cin>>s;
		mp[s]=0;
	}
	cin>>m;
	while(m--)
	{
		string s;cin>>s;
		if(!mp.count(s))
		{
			cout<<"WRONG"<<endl;
		}
		else {
			mp[s]++;
			if(mp[s]==1)cout<<"OK"<<endl;
			else cout<<"REPEAT"<<endl;
		}
	}
	return 0;
}
